package com.uuj.dome.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * ClassName:TestServlet
 * PACKAGE_NAME:com.uuj.dome.servlet
 */
@WebServlet(urlPatterns = "/test2")
public class TestServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // 设置返回类型为json
        resp.setContentType("application/json");
        // 设置返回字符集
        resp.setCharacterEncoding("utf-8");
        // 输入对象
        PrintWriter writer = resp.getWriter();
        writer.write("执行TestServlet 内 doGet 方法成功");
        writer.close();
    }
}
